package tools;

import android.media.MediaPlayer;

/**
 * Provides a singleton MediaPlayer.
 * @author SW6E
 *
 */
public final class SingletonMediaPlayer extends MediaPlayer {
	
	private static MediaPlayer sMediaplayer;
	
	private SingletonMediaPlayer() {
	    super();
	}
	
	/**
	 * Constructs or returns the MediaPlayer.
	 * @return
	 */
	public static MediaPlayer getMediaPlayer()
	{
		if (sMediaplayer != null) {
			sMediaplayer.stop();
			sMediaplayer.release();
		}
		
		sMediaplayer = new MediaPlayer();
		return sMediaplayer;
	}
}
